package com.bmd.backgroundmanger.mapper;

import com.bmd.backgroundmanger.entity.ExamPaper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;

/**
 * <p>
 * 试卷 Mapper 接口
 * </p>
 *
 * @author 刷题App
 * @since 2024-12-19
 */
@Mapper
public interface ExamPaperMapper extends BaseMapper<ExamPaper> {

    /**
     * 查询已发布的试卷列表
     */
    @Select("SELECT * FROM exam_papers WHERE status = 'published' ORDER BY create_time DESC")
    List<ExamPaper> selectPublishedPapers();

    /**
     * 根据状态查询试卷列表
     */
    @Select("SELECT * FROM exam_papers WHERE status = #{status} ORDER BY create_time DESC")
    List<ExamPaper> selectByStatus(String status);

    /**
     * 查询试卷包含的题目数量
     */
    @Select("SELECT COUNT(*) FROM paper_questions WHERE paper_id = #{paperId}")
    Integer selectQuestionCount(Integer paperId);
} 